package com.example.demo.util;

import com.example.demo.service.SupperService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.ui.Model;

import java.util.List;

public class PageInfoTool {

    public static final Integer pageSize = 3;

    public static void pageInfoConfig(Integer pageNum,
                                      Model model,
                                      SupperService supperService,
                                      Object object
    ) {
        if (pageNum == null) {
            pageNum = 1;
        }
        PageHelper.startPage(pageNum, pageSize);
        List<Object> list = supperService.getList(object);
        PageInfo pageInfo = new PageInfo(list);
        model.addAttribute("pageInfo", pageInfo);
    }

}
